<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="ja" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<!-- meta -->
<meta name="keywords" content="">
<meta name="description" content="">
<!-- /meta -->
<title>データ検索</title>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/base.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/headerfooter.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/ulol.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/arrow.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/elements.css">
<!-- admin -->
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/base_admin.css">
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/elements_admin.css">
<!-- /admin -->
<script type="text/javascript" src="<%= request.getContextPath() %>/common/js/library.js"></script>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/for_winie3.css">
<!--[if gte IE 5]>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/for_over_winie5.css">
<![endif]-->
<!--[if IE 5]>
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/common/css/for_winie5.css">
<![endif]-->

<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/interface/dchDWR.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/util.js'></script>
<SCRIPT type="text/javascript">

	/*再表示ボタン処理*/
	function pageShow(page){
	    document.frm1.currentPage.value = page;

		document.frm1.action = "<%= request.getContextPath() %>/outputdata/searchstate";
	   	document.frm1.submit();

	}

	/**
	* 指定したデータ種別に対してメタデータスキーマコンボボックスリスト内容を取得
	**/
	function changeDataType(){
		var dataType =DWRUtil.getValue("dataType");
	    dchDWR.getOutputSchemaList(dataType, searchSchemaListHandler);
	}

	function searchSchemaListHandler(data){
		DWRUtil.removeAllOptions("metaSchemaType");
        /*コンボボックスのoptionのvalueに設定するフィールドを3番目の引数に、
        表示するテキストのフィールドを4番目の引数とする。*/
        DWRUtil.addOptions("metaSchemaType", data, "schemaid", "name");
	}

	function doEdit(id, sort, schemaid){

		var action;

		document.getElementById("editDataid").value = id;
		document.getElementById("editDatasort").value = sort;
		document.getElementById("editSchemaid").value = schemaid;

		document.frm2.action = "<%= request.getContextPath() %>/outputdata/editInit";
		document.frm2.submit();
	}

	function doCopy(id, sort, schemaid){

		var action;

		document.getElementById("editDataid").value = id;
		document.getElementById("editDatasort").value = sort;
		document.getElementById("editSchemaid").value = schemaid;

		document.frm2.action = "<%= request.getContextPath() %>/outputdata/copyInit";
		document.frm2.submit();
	}

	function doDelete(id, sort, schemaid){

		var action;

		document.getElementById("editDataid").value = id;
		document.getElementById("editDatasort").value = sort;
		document.getElementById("editSchemaid").value = schemaid;

		document.frm2.action = "<%= request.getContextPath() %>/outputdata/delInit";
		document.frm2.submit();
	}

	function oyaSelect(id, name) {
		window.opener.oyaSelect(id, name);
		window.close();
	}


	 /*
	 * 指定した検索キーワードで検索件数を取得
	 */
	function search(){
		var dataType =DWRUtil.getValue("dataType");
		var metaSchemaType = DWRUtil.getValue("metaSchemaType");
		var keyword= DWRUtil.getValue("keyword");
		var popupSign= DWRUtil.getValue("popupSign");

		var param ={dataType:dataType,schemaid:metaSchemaType,keyword:keyword,popupSign:popupSign};
 		dchDWR.getSearchOutputDataResultCnt(param,searchResultHandler);
	}

	/**
	* 検索結果の件数メッセージを表示する
	* 確認画面からYesを選択した場合、検索結果を取得処理を呼び出す
	*/
	function searchResultHandler(data){
		var dataCnt = eval(data);
		if(dataCnt == 0){
			alert("データが存在しません。");
			return -1;
		}else if(dataCnt > 0){
			if(confirm(dataCnt+"件あります。表示しますか？")){
				searchAction();
			}
		}
	}

	/**
	* 検索結果取得処理を行う
	*
	*/
	function searchAction(){
		document.frm1.submit();
	}

	//検索後に表示件数を変えた場合、再表示を行う
	function viewPageCntChangeHandler(){
		var totalPage = eval(document.frm1.totalPage.value);
		if(totalPage  > 0){
		 document.frm1.currentPage.value='';
		 document.frm1.submit();
		}
	}

</SCRIPT>
</head>
<body id="dch">

<s:if test='%{popupSign != "1"}'>
<!-- === headerArea === -->
<div id="headerArea">
<a name="pageTop" id="pageTop"></a>
<jsp:include page="/common/include/header.jsp" />
</div><!-- === /headerArea === -->
</s:if>
<!-- === mainArea === -->
<div id="mainArea">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
	<tr valign="top">
		<s:if test='%{popupSign != "1"}'>
		<td width="140" id="leftArea">
		<!-- === leftArea === -->
			<!-- listA01 -->

				<jsp:include page="output_menu.jsp" />

			<!-- /listA01 -->
		<!-- === /leftArea === -->
		</td>
		</s:if>
		<td width="20"><img src="<%= request.getContextPath() %>/common/images/spacer.gif" width="20" height="4" border="0" alt=""></td>
		<td id="contentsArea">
		<!-- === contentsArea === -->
			<!-- headingLv01Block -->
			<div class="headingLv01Block">
				<!-- headingLv01 -->
				<h1>データ検索</h1>
				<!-- /headingLv01 -->
			</div>
			<!-- /headingLv01Block -->
			<!-- columnB01 -->
			<div class="columnB01">
			 <s:fielderror/>
			 <s:actionerror/>
			 <s:actionmessage/>
			</div>
			<!-- /columnB01 -->
			<!-- headingLv02 -->
			<div class="headingLv02">
			<table border="0" cellspacing="0" cellpadding="5" width="558">
				<tr>
					<td><p><em>検索条件</em></p></td>
				</tr>
			</table>
			</div>
			<!-- /headingLv02 -->
			<form action="<%= request.getContextPath() %>/outputdata/search" name="frm1" method="get">
			<!-- リンク値 -->
			<s:hidden name="popupSign"/>
			<s:hidden name="currentPage"/>
			<!-- tableBlock -->
			<div class="tableBlock">
				<!-- tableA01 -->
				<div class="tableA01">
				<table border="1" cellspacing="0" cellpadding="5" width="558">
					<tr>
						<th class="lv01B" width="130"><label for="sDataType">データ種別</label></th>
						<th width="11" class="error">&nbsp;</th>
						<td>
							<s:if test='%{popupSign == "1"}'>
								<s:select emptyOption="true"  id ="dataType" list="#{'001':'作成機関の概要','002':'目録データ概要','003':'資料群全体','004':'サブフォンド','005':'シリーズ','006':'アイテム','007':'ファイル'}" name="dataType"  disabled="true" />
								<s:hidden name="dataType" />
							</s:if>
							<s:else>
								<s:select emptyOption="true"  id ="dataType" list="#{'001':'作成機関の概要','002':'目録データ概要','003':'資料群全体','004':'サブフォンド','005':'シリーズ','006':'アイテム','007':'ファイル'}" name="dataType" onchange="changeDataType()" />
							</s:else>
						</td>
					</tr>
					<tr>
						<th class="lv01B" width="130"><label for="sMetaData">メタデータスキーマ</label></th>
						<th width="11" class="error">&nbsp;</th>
						<td>
							<s:if test='%{popupSign == "1"}'>
							 	<span id="sMetaDataSpan"><s:select emptyOption="true"  list="optionList" name="schemaid"  listKey="schemaid"  listValue="name" id="metaSchemaType" disabled="true" /><s:hidden name="schemaid" /></span>
							</s:if>
							<s:else>
								<span id="sMetaDataSpan"><s:select emptyOption="true"  list="optionList" name="schemaid"  listKey="schemaid"  listValue="name" id="metaSchemaType" /></span>
							</s:else>
						</td>
					</tr>
					<tr>
						<!-- ラベル --><th class="lv01B" width="130"><label for="sKeyword">あいまい検索</label></th>
						<!-- エラー --><th width="11" class="error">&nbsp;</th>
						<!-- 内容 --><td colspan="4">
							<s:textfield name="keyword" id="keyword" size="35"/>
						</td>
					</tr>

				</table>
				</div>
				<!-- /tableA01 -->
			</div>
			<!-- /tableBlock -->

			<!-- pageNaviC01 -->
			<div class="pageNaviC01">
			<table border="0" cellspacing="0" cellpadding="10" width="558">
				<tr>
					<td class="left">&nbsp;</td>
					<td width="130" class="right" align="right"><p><input type="button" id="searchBtn" value="検索する" style="width:130px" onclick="search()"></p></td>
				</tr>
			</table>
			</div>

			<div class="headingLv01">
			<table border="0" cellspacing="0" cellpadding="5" width="558">
				<tr>
					<td align="right"><p><em>表示件数：<s:select list="#{'10':'10','20':'20','30':'30','50':'50','100':'100'}" name="viewPageCnt"/></em></p></td>
				</tr>
			</table>
			</div>

			<div class="headingLv02">
			<table border="0" cellspacing="0" cellpadding="5" width="558">
				<tr>
					<td><p><em>データ一覧<br></em></p></td>
				</tr>
			</table>
			</div>
			<!-- pageNaviB01 -->
			<s:if test='page.totalCnt > 0'>
			<div class="pageNaviB01">
			<table border="0" cellspacing="0" cellpadding="0"  width="800">
				<tr valign="top">
					<td align="left" width="100"><p>結果：${page.totalCnt}件</p></td>
					<td width="50">&nbsp;</td>
					<td align="center">
						<table border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td><p>
								    <s:if test='page.currentPage > 1'><a href="javascript:pageShow(1)">＜最初のページ</a>&nbsp;</s:if>
									<s:if test='(page.currentPage > page.startPage) || (page.previousPage > 0)'><a href="javascript:pageShow(${page.currentPage-1})">&lt;&lt;前を見る</a>…</s:if>&nbsp;&nbsp;
									<s:iterator begin="page.startPage" end="page.endPage" status="num" >
										<s:if test='(#num.index+page.startPage)==(page.currentPage)'>${num.index+page.startPage}</s:if>
										<s:else>
											<a href="javascript:pageShow(${num.index+page.startPage})">${num.index+page.startPage}</a>
										</s:else>
										<s:if test='!(#num.last)'>|</s:if>
									</s:iterator>
									<s:if test='page.endPage < page.totalPage'>&nbsp;…&nbsp;&nbsp;<a href="javascript:pageShow(${page.currentPage+1})">次のページ&gt;&gt;</a></s:if>
									<s:if test='page.currentPage != page.totalPage'>&nbsp;&nbsp;<a href="javascript:pageShow(${page.totalPage})">最後のページ></a></s:if></p>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			</div>

			<!-- /pageNaviB01 -->
			<!-- /headingLv02 -->
			<!-- pageNaviB01 -->
			<!-- /pageNaviB01 -->
			<!-- tableBlock -->
			<div class="tableBlock">
				<!-- tableA01 -->
				<div class="tableA01">
				<table border="1" cellspacing="0" cellpadding="5">
					<tr>
						<th class="lv01B">処理</th>
						<th class="lv01B">種別</th>
						<th class="lv01B">メタデータスキーマ</th>
						<th class="lv01B">データ名</th>
						<th class="lv01B">登録者</th>
						<th class="lv01B">登録日付</th>
						<th class="lv01B">最終更新者</th>
						<th class="lv01B">最終更新日付</th>
					</tr>
					<s:iterator value="page.dataList">
						<tr>
								<td>
									<s:if test='%{popupSign == "1"}'>
										<input type="button" value="選択" onclick='oyaSelect("<c:out value="${id}"/>","<c:out value="${name}"/>")'>&nbsp;
									</s:if>
									<s:else>
										<input type="button" value="編集" onclick="doEdit('<s:property value="id"/>','<s:property value="sort"/>','<s:property value="schemaId"/>')">&nbsp;
								 		<input type="button" value="コピー" onclick="doCopy('<s:property value="id"/>','<s:property value="sort"/>','<s:property value="schemaId"/>')">&nbsp;
								    	<input type="button" value="削除" onclick="doDelete('<s:property value="id"/>','<s:property value="sort"/>','<s:property value="schemaId"/>')">
									</s:else>
								</td>
								<td><s:property value="%{getSortName(sort)}"/></td>
								<td><s:property value="schemaName"/></td>
								<td><s:property value="name"/></td>
								<td><s:property value="createUser"/></td>
								<td><s:property value="createDate"/></td>
								<td><s:property value="modifyUser"/></td>
								<td><s:property value="modifyDate"/></td>
						</tr>
					</s:iterator>
				</table>
				</div>
				<!-- /tableA01 -->
			</div>
			<div class="pageNaviB01">
			<table border="0" cellspacing="0" cellpadding="0" width="800">
				<tr valign="top">
					<td align="left" width="100">&nbsp;</td>
					<td width="50">&nbsp;</td>
					<td align="center">
							<table border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td><p>
								    <s:if test='page.currentPage > 1'><a href="javascript:pageShow(1)">＜最初のページ</a>&nbsp;</s:if>
									<s:if test='(page.currentPage > page.startPage) || (page.previousPage > 0)'><a href="javascript:pageShow(${page.currentPage-1})">&lt;&lt;前を見る</a>…</s:if>&nbsp;&nbsp;
									<s:iterator begin="page.startPage" end="page.endPage" status="num" >
										<s:if test='(#num.index+page.startPage)==(page.currentPage)'>${num.index+page.startPage}</s:if>
										<s:else>
											<a href="javascript:pageShow(${num.index+page.startPage})">${num.index+page.startPage}</a>
										</s:else>
										<s:if test='!(#num.last)'>|</s:if>
									</s:iterator>
									<s:if test='page.endPage < page.totalPage'>&nbsp;…&nbsp;&nbsp;<a href="javascript:pageShow(${page.currentPage+1})">次のページ&gt;&gt;</a></s:if>
									<s:if test='page.currentPage != page.totalPage'>&nbsp;&nbsp;<a href="javascript:pageShow(${page.totalPage})">最後のページ></a></s:if></p>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			</div>
			</s:if>
			<!-- /pageNaviB01 -->

			<!-- /pageNaviC01 -->
			</form>
			<form name="frm2" method="get">
				<input type="hidden" name="dataid" id="editDataid"/>
				<input type="hidden" name="schemaid" id="editSchemaid"/>
				<input type="hidden" name="datasort" id="editDatasort"/>
			</form>
		<!-- === /contentsArea === -->
		</td>
		<td width="16"><img src="<%= request.getContextPath() %>/common/images/spacer.gif" width="16" height="4" border="0" alt=""></td>
	</tr>
</table>
</div><!-- === /mainArea === -->
<!-- === footerArea === -->
<div id="footerArea">
<jsp:include page="/common/include/footer.jsp" />
<!--#include virtual="<%= request.getContextPath() %>/common/include/footer.html" -->
</div><!-- === /footerArea === -->
</body>
</html>
<!-- System Architect is COOBA Corp
	Copyright 2010 COOBA Corp All rights reserved -->